layui.use(['layer', 'form', 'util', 'element'], function() {
	var $ = layui.jquery,
		layer = layui.layer,
		element = layui.element(),
		util = layui.util;
		var form = layui.form(),
            noticeId = getQueryString("noticeId",window.location.href);
	/**
	 * 使用内部工具组件
	 */
	util.fixbar();
	/**
	 ****************************jq扩展函数*******************************v**
	 */
    $("#noticeId").val(noticeId);
	$.ajax({
		type: "get",
		url: url + '/ic-iot/notice/' + noticeId,
		dataType: 'json',
		async: false,
		beforeSend: function(request) {
            request.setRequestHeader("accessToken", accessToken);
        },
		success: function(data) {
			if(data['code'] == 1){

				$("#msg").val(data.result.msg);
				// $("#companyPhone").val(data.result.companyPhone);
				// $("#companyEmail").val(data.result.companyEmail);
				// $("#companyAddress").val(data.result.companyAddress);
				// $("#companyContact").val(data.result.companyContact);
			}else{
				ifajax(data);
			}
		}
	});

	form.on('submit(enterprise)', function(data){
		var data = formToJson($("#notice_add"));
		$.ajax({
			type: "post",
			url: url + '/ic-iot/notice/update',
			data: data,
			dataType: 'json',
			async: false,
			contentType: "application/json; charset=utf-8",
			beforeSend: function(request) {
	            request.setRequestHeader("accessToken", accessToken);
	        },
			success: function(data) {
				
				if(data['code'] == 1){
					layer.msg(data['description']);
					setTimeout(function() {
						window.parent.location.reload();
					}, 2000)
				}else{
					ifajax(data);
				}
			}
		});
	   return false;
    });

});